<%@ page language="java" contentType="text/html; charset=UTF-8"	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="perm" uri="/WEB-INF/tld/perm.tld"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<script>var ctx="${ctx}";</script>
<style>
.row input{
	margin-top: 5px;
}
.row select{
	margin-top: 5px;
}
</style>
<div class="form-horizontal" role="form" >
	<input id="id" value="${sysDict.id}"  type="hidden"/>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">选择所属节点:</label>
        <div class="col-md-9">
        	<select id="parentId" placeholder="选择所属节点" class="form-control chosen-select" tabindex="4">
				<option value="" >选择所属节点</option>
			</select>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">名称:</label>
        <div class="col-md-9">
        	 <input id="lable" value="${sysDict.lable}"  type="text" placeholder="名称" class="form-control" name="lable"/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">类型:</label>
        <div class="col-md-9">
        	 <input id="type" value="${sysDict.type}" type="text" placeholder="类型" class="form-control" name=type/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">值:</label>
        <div class="col-md-9">
        	 <input id="value" value="${sysDict.value}" type="text" placeholder="值" class="form-control" name="value"/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">分类:</label>
        <div class="col-md-9">
        	 <input id="descs" value="${sysDict.descs}"  type="text" placeholder="分类" class="form-control" name="descs"/>
        </div>
    </div>
    <div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">描述:</label>
        <div class="col-md-9">
        	 <input id="sort" value="${sysDict.sort}"  type="text" placeholder="描述" class="form-control" name="sort"/>
        </div>
    </div>
	<div class="form-group">
 	    <label class="col-md-3 col-sm-3 control-label">启用:</label>
        <div class="col-md-9">
        	 <input type="checkbox" class="js-switch" name="status" checked="checked"/>
        </div>
    </div>
</div>

<script>
var elems = Array.prototype.slice.call(document.querySelectorAll('.js-switch'));
elems.forEach(function(html) {
	var switchery = new Switchery(html);
});	
$.ajax({  
	url:'${ctx}/dict/list',  		 					
	type: 'POST',
	dataType:'json',  
	data:{
		status:"1",	
		parentId:"-1"					
	}, 
	success:function(response){
		if(response.code==0){
			var html=[];
			var data=response.data||[];
			for(var i=0;i<data.length;i++){
				html.push('<option value="'+data[i].id+'">'+data[i].type+' | '+data[i].lable+' | '+data[i].value+'</option>');
			}
			$("#parentId").append(html.join(""));
			$("#parentId").trigger("chosen:updated");
		}
	 }  
 });
 
 $("#parentId").chosen({ width: '100%' });
 
</script>
